home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / ErrMgr.h < prev    next >
Text File  |  1991-04-17  |  5KB  |  127 lines

  1. /************************************************************
  2.  
  3. Created: Thursday, September 7, 1989 at 9:13 PM
  4.     ErrMgr.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.     <<< Error File Manager Routines Interface File >>>
  9.     
  10.     Copyright Apple Computer, Inc.    1987-1990
  11.     All rights reserved
  12.     
  13.     This file contains:
  14.     
  15.     InitErrMgr(toolname, sysename, Nbrs)  - ErrMgr initialization
  16.     CloseErrMgr()                          - Close ErrMgr message files
  17.     GetSysErrText(Nbr, Msg)               - Get a system error message for a number
  18.     GetToolErrText(Nbr, Insert, Msg)      - Get a tool error message for a number
  19.     AddErrInsert(insert, msgString)       - Add an insert to a message
  20.     addInserts(msgString, insert,...)      - Add a number of inserts to a message
  21.     
  22.  
  23. ************************************************************/
  24.  
  25.  
  26. #ifndef __ERRMGR__
  27. #define __ERRMGR__
  28.  
  29. #ifndef __TYPES__
  30. #include <Types.h>
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. extern void InitErrMgr(char *toolErrFilename,char *sysErrFilename,Boolean showToolErrNbrs);
  37. /*
  38.     ErrMgr initialization.This must be done before using any other ErrMgr
  39.     routine.  Set showToolErrNbrs to true if you want all tool messages to contain
  40.     the error number following the message text enclosed in parentheses (e.g.,
  41.     "<msg txt> ([OS] Error <n>)"; system error messages always contain the error
  42.     number).  The toolErrFileName parameter is used to specify the name of a
  43.     tool-specific error file, and should be the NULL or a null string if not used
  44.     (or if the tool's data fork is to be used as the error file, see
  45.     GetToolErrText for futher details). The sysErrFileName parameter is used to
  46.     specify the name of a system error file, and should normally be the NULL or a
  47.     null string, which causes the ErrMgr to look in the MPW Shell directory for
  48.     "SysErrs.Err" (see GetSysErrText).
  49.     
  50.     If InitErrMgr is NOT called prior to calling GetSysErrText or GetToolErrText,
  51.     then those routines, the first time they are called, will call InitErrMgr as
  52.     InitErrMgr(NULL, NULL, true).
  53.     
  54.     The following global may be set to true to allow a C caller to process all
  55.     strings as Pascal strings:*/
  56.     
  57.     extern Boolean pascalStrings;    /* set to true for Pascal strings*//*
  58.     
  59.     This should be set PRIOR to calling InitErrMgr.  Once set, ALL strings, both
  60.     those passed to the ErrMgr as filenames and error message inserts, as well as
  61.     the messages returned by the ErrMgr will be Pascal strings.  There is NO
  62.     guarantee a '\0' byte is at the end of the string.    Results are unpredictable
  63.     if pascalStringsis set false after it has been set true!
  64.     
  65. */
  66.  
  67. extern void CloseErrMgr(void);
  68. /*
  69.     Ideally a CloseErrMgr should be done at the end of execution to make sure all
  70.     files opened by the ErrMgr are closed.    You can let normal program termination
  71.     do the closing.  But if you are a purist...
  72. */
  73.  
  74. extern char *GetSysErrText(short msgNbr,char *errMsg);
  75. /*
  76.     Get the error message text corresponding to system error number errNbr from
  77.     the system error message file (whose name was specified in the InitErrMgr
  78.     call).    The text of the message is returned in errMsg and the function returns
  79.     a pointer to errMsg.  The maximum length of the message is limited to 254
  80.     characters.
  81.     
  82.     Note, if a system message filename was not specified to InitErrMgr, then the
  83.     ErrMgr assumes the message file contained in the file "SysErrs.Err".  This
  84.     file is first accessed as "{ShellDirectory}SysErrs.Err" on the assumption that
  85.     SysErrs.Err is kept in the same directory as the MPW Shell.  If the file
  86.     cannot be opened, then an open is attempted on "SysErrs.Err" in the System
  87.     Folder.
  88. */
  89.  
  90. extern char *GetToolErrText(short msgNbr,char *errInsert,char *errMsg); 
  91. /*
  92.     Get the error message text corresponding to tool error number errNbr from
  93.     the tool error message file (whose name was specified in the InitErrMgr
  94.     call).    The text of the message is returned in errMsg and the function returns
  95.     a pointer to errMsg.  The maximum length of the message is limited to 254
  96.     characters.  If the message is to have an insert, then ErrInsert should be a
  97.     pointer to it.    Otherwise it should be either be a null string or a NULL
  98.     pointer.
  99.     
  100.     Inserts are indicated in error messages by specifying a '^' to indicate where
  101.     the insert is to be placed.
  102.     
  103.     Note, if a tool message filename was not specified to InitErrMgr, then the
  104.     ErrMgr assumes the message file contained in the data fork of the tool calling
  105.     the ErrMgr.  This name is contained in the Shell variable {Command} and the
  106.     value of that variable is used to open the error message file.
  107. */
  108.  
  109. extern void AddErrInsert(unsigned char *insert,unsigned char *msgString);
  110. /*
  111.     Add another insert to an error message string.This call is used when more
  112.     than one insert is to be added to a message (because it contains more than
  113.     one '^' character).
  114. */
  115.  
  116. extern unsigned char *addInserts(unsigned char *msgString,unsigned char *insert,
  117.     ... );
  118. /*
  119.     Add a set of inserts to an error message string.  AddErrInsert is called for
  120.     each insert parameter specified.
  121. */
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125.  
  126. #endif
  127.